var R = require('ramda')

// 调试函数
let debug = function(f){console.log(f);return f}

//对一个函数取反
let n = R.curry((f, arg) => !f(arg))

//判断是否是数组
let isArr = (arr) => (arr instanceof Array)

//判断是否一维数组
let isTdim = (arr) => arr.reduce((o1, o2) => o1&&!isArr(o2), true)

//多维数组变一维数组
let flat = (arr) => isTdim(arr) ? arr : flat(Array.prototype.concat.apply([],arr))

exports.flat = flat
exports.n = n
exports.debug = debug

if (require.main === module) {
    // console.log(flat([[],1,2,[1,2,[10,[],11],5],[5,6],4]))
     ary = []
    for (let i = 0; i < 305690; i++) {
        ary.push([i, i+1])
    }
    console.log(ary.length)
    console.log(flat(ary).length)
}